package io.itit.ecp.admin.server.service.impl;

import icu.mhb.mybatisplus.plugln.base.service.impl.JoinServiceImpl;
import io.itit.ecp.admin.server.entity.CarbonRevenueForecastDataEntity;
import io.itit.ecp.admin.server.mapper.CarbonRevenueForecastDataMapper;
import io.itit.ecp.admin.server.service.ICarbonRevenueForecastDataService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

@Service
@RequiredArgsConstructor
public class CarbonRevenueForecastDataServiceImpl extends JoinServiceImpl<CarbonRevenueForecastDataMapper, CarbonRevenueForecastDataEntity>
        implements ICarbonRevenueForecastDataService {

    @Override
    public List<CarbonRevenueForecastDataEntity> queryForList(String sceneProjectId, String sceneEdificeId, String sceneFloorId,
                                                              String sceneRoomId, LocalDateTime start, LocalDateTime end) {
        return lambdaQuery()
                .eq(StringUtils.isNotEmpty(sceneProjectId), CarbonRevenueForecastDataEntity::getSceneProjectId, sceneProjectId)
                .eq(StringUtils.isNotEmpty(sceneEdificeId), CarbonRevenueForecastDataEntity::getSceneEdificeId, sceneEdificeId)
                .eq(StringUtils.isNotEmpty(sceneFloorId), CarbonRevenueForecastDataEntity::getSceneFloorId, sceneFloorId)
                .eq(StringUtils.isNotEmpty(sceneRoomId), CarbonRevenueForecastDataEntity::getSceneRoomId, sceneRoomId)
                .ge(Objects.nonNull(start), CarbonRevenueForecastDataEntity::getCreateTm, start)
                .le(Objects.nonNull(end), CarbonRevenueForecastDataEntity::getCreateTm, end)
                .list();
    }
}
